package org.example;

import java.util.*;

public class Collectionss_Demo4 {
    public static void main(String[] args) {
        HashMap<String, ArrayList<String>> map = new HashMap<>();
        ArrayList<String> list1 = new ArrayList<>();
        Collections.addAll(list1, "南京市", "扬州市", "苏州市");
        ArrayList<String> list2 = new ArrayList<>();
        Collections.addAll(list2, "武汉市", "孝感市", "宜昌市");
        ArrayList<String> list3 = new ArrayList<>();
        Collections.addAll(list3, "长沙市", "株洲市", "湘潭市");
        map.put("江苏省", list1);
        map.put("湖北省", list2);
        map.put("湖南省", list3);
//键值对遍历
        Set<Map.Entry<String, ArrayList<String>>> set = map.entrySet();
        for (Map.Entry<String, ArrayList<String>> entry : set) {
            String key = entry.getKey();
            ArrayList<String> vaule = entry.getValue();
            StringJoiner sj = new StringJoiner(",", " ", " ");
            for (String city : vaule) {
                sj.add(city);
            }
            System.out.println(key + " = " + sj);
        }

    }
}
